Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@analytics/localstorage-utils

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@analytics/localstorage-utils

Tiny LocalStorage utility library

  • 0.1.10
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
127K
decreased by-8.89%
Maintainers
1
Weekly downloads
 
Created
Source

LocalStorage Utilities

A tiny localStorage utility library with fallbacks in 231 bytes.

This module will automatically fail back to global window storage if localStorage is not available.

Exposes hasLocalStorage, getItem, setItem, & removeItem functions.

See live demo.

How to install

Install @analytics/localstorage-utils from npm.

npm install @analytics/localstorage-utils

API

Below is the api for @analytics/localstorage-utils. These utilities are tree-shakable.

hasLocalStorage

Check if localStorage is supported

import { hasLocalStorage } from '@analytics/localstorage-utils'

if (hasLocalStorage()) {
  // Use local storage 
}

getItem

Get a localStorage value.

import { getItem } from '@analytics/localstorage-utils'

const value = getItem('cookie-key')

setItem

Set a localStorage value.

import { setItem } from '@analytics/localstorage-utils'

setItem('item-key', 'a')

removeItem

Delete a localStorage value.

import { removeItem } from '@analytics/localstorage-utils'

removeItem('key')

Keywords

FAQs

Package last updated on 27 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc